package com.ehotting.edsta.mqbd.test.zw.aop;

import com.alibaba.fastjson.JSON;
import com.ehotting.edsta.mqbd.test.zw.controller.SimulationWsController;
import com.ehotting.mqbd.zw.api.constants.ActionConstants;
import com.ehotting.mqbd.zw.api.domain.netty.ZwCommPacket;
import com.ehotting.mqbd.zw.client.aop.AbstractZwMqActionAspect;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Slf4j
public class ZwMqActionAspect extends AbstractZwMqActionAspect {

    @Autowired
    private SimulationWsController simulationWsController;

    public void sendToQueue(ZwCommPacket request) {
        short cmd = request.getHead().getCmd();
        if (cmd == ActionConstants.Cmd_ClusterInfoQuery.getZwCommandVal()){
            return;
        }
        try {
            Long agentId = request.getUserId();
            simulationWsController.sendUserMessage(JSON.toJSONString(request),agentId.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
